package jssia.database.mysql.columns;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class BigIntColumn extends Column {

    private static final long LOWER = -9223372036854775808l;
    private static final long UPPER = 9223372036854775807l;

    public BigIntColumn() {
    }

    public long get(ResultSet rs) throws SQLException {
        return rs.getLong(fullyQualifiedName);
    }

    public void set(PreparedStatement ps, int index, long value) throws SQLException {
        if (value < LOWER || value > UPPER)
            throw new IllegalArgumentException("Invalid value of " + value + ", must be between " + LOWER + " and " + UPPER);
        ps.setLong(index, value);
    }
}
